package com.briup.day16;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Test_Collections {
    public static void main(String[] args) {
        List<Integer> list1=new ArrayList<>();
        Collections.addAll(list1,1,2,3,4,5,6,7,8,9,10);
        System.out.println(list1);
        //max 获取一個集合中的最大值
        Integer max=Collections.max(list1);
        System.out.println(max);
        Integer min = Collections.min(list1);
        System.out.println(min);
//        Collections.reverse(list1);
//        System.out.println(list1);
        //sort对集合元素进行排序，默认升序

        Comparator<Integer> comparator=new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        };
        Collections.sort(list1,comparator);
        System.out.println(list1);
        Collections.shuffle(list1);
        System.out.println(list1);
        Collections.fill(list1,20);
        System.out.println(list1);
    }
}
